package com.jdk21.api.common;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class PageResult<T> implements Serializable {

    private Long count;

    private Integer pageSize;

    private Boolean end;

    private List<T> list;

    private String anchor;

    public static <T> PageResult<T> newPageResult(List<T> list, boolean end) {
        PageResult<T> result = new PageResult<>();
        result.setEnd(end);
        result.setList(list);
        return result;
    }

    public static <T> PageResult<T> newPageResult(List<T> list, Long count, Integer pageSize, boolean end) {
        PageResult<T> result = new PageResult<>();
        result.setEnd(end);
        result.setCount(count);
        result.setPageSize(pageSize);
        result.setList(list);
        return result;
    }
}
